﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;

namespace WeishaLearningSystemRegester
{
    public class ConvertToAnyValue
    {
        // Token: 0x170000B2 RID: 178
        // (get) Token: 0x060001CB RID: 459 RVA: 0x0000DAF4 File Offset: 0x0000BCF4
        // (set) Token: 0x060001CC RID: 460 RVA: 0x0000DB11 File Offset: 0x0000BD11
        public string ParaValue
        {
            get
            {
                return this._paravlue.ToString();
            }
            set
            {
                this._paravlue = value;
            }
        }

        // Token: 0x170000B3 RID: 179
        // (get) Token: 0x060001CD RID: 461 RVA: 0x0000DB1C File Offset: 0x0000BD1C
        // (set) Token: 0x060001CE RID: 462 RVA: 0x0000DB34 File Offset: 0x0000BD34
        public string ParaKey
        {
            get
            {
                return this._parakey;
            }
            set
            {
                this._parakey = value;
            }
        }

        // Token: 0x170000B4 RID: 180
        // (get) Token: 0x060001CF RID: 463 RVA: 0x0000DB40 File Offset: 0x0000BD40
        // (set) Token: 0x060001D0 RID: 464 RVA: 0x0000DB58 File Offset: 0x0000BD58
        public string Unit
        {
            get
            {
                return this._unit;
            }
            set
            {
                this._unit = value;
            }
        }

        // Token: 0x060001D1 RID: 465 RVA: 0x0000DB62 File Offset: 0x0000BD62
        public ConvertToAnyValue()
        {
        }

        // Token: 0x060001D2 RID: 466 RVA: 0x0000DB82 File Offset: 0x0000BD82
        public ConvertToAnyValue(object para)
        {
            this._paravlue = para;
        }

        // Token: 0x060001D3 RID: 467 RVA: 0x0000DBA9 File Offset: 0x0000BDA9
        public ConvertToAnyValue(string para)
        {
            this._paravlue = (string.IsNullOrWhiteSpace(para) ? "" : para);
        }

        // Token: 0x060001D4 RID: 468 RVA: 0x0000DB82 File Offset: 0x0000BD82
        public ConvertToAnyValue(string para, string unit)
        {
            this._paravlue = para;
        }

        // Token: 0x060001D5 RID: 469 RVA: 0x0000DBE0 File Offset: 0x0000BDE0
        public static ConvertToAnyValue Get(string para)
        {
            return new ConvertToAnyValue(para);
        }

        // Token: 0x170000B5 RID: 181
        // (get) Token: 0x060001D6 RID: 470 RVA: 0x0000DBF8 File Offset: 0x0000BDF8
        public int? Int16
        {
            get
            {
                bool flag = this._paravlue == null;
                int? num;
                if (flag)
                {
                    num = null;
                }
                else
                {
                    try
                    {
                        num = new int?((int)Convert.ToInt16(this._paravlue));
                    }
                    catch
                    {
                        Regex regex = new Regex("\\d+");
                        Match match = regex.Match(this.String);
                        bool success = match.Success;
                        if (success)
                        {
                            string value = match.Groups[0].Value;
                            num = new int?((int)Convert.ToInt16(value));
                        }
                        else
                        {
                            num = null;
                        }
                    }
                }
                return num;
            }
        }

        // Token: 0x170000B6 RID: 182
        // (get) Token: 0x060001D7 RID: 471 RVA: 0x0000DCA0 File Offset: 0x0000BEA0
        public int? Int32
        {
            get
            {
                bool flag = this._paravlue == null;
                int? num;
                if (flag)
                {
                    num = null;
                }
                else
                {
                    try
                    {
                        num = new int?(Convert.ToInt32(this._paravlue));
                    }
                    catch
                    {
                        Regex regex = new Regex("\\d+");
                        Match match = regex.Match(this.String);
                        bool success = match.Success;
                        if (success)
                        {
                            string value = match.Groups[0].Value;
                            num = new int?(Convert.ToInt32(value));
                        }
                        else
                        {
                            num = null;
                        }
                    }
                }
                return num;
            }
        }

        // Token: 0x170000B7 RID: 183
        // (get) Token: 0x060001D8 RID: 472 RVA: 0x0000DD48 File Offset: 0x0000BF48
        public long? Int64
        {
            get
            {
                bool flag = this._paravlue == null;
                long? num;
                if (flag)
                {
                    num = null;
                }
                else
                {
                    try
                    {
                        num = new long?(Convert.ToInt64(this._paravlue));
                    }
                    catch
                    {
                        Regex regex = new Regex("\\d+");
                        Match match = regex.Match(this.String);
                        bool success = match.Success;
                        if (success)
                        {
                            string value = match.Groups[0].Value;
                            num = new long?(Convert.ToInt64(value));
                        }
                        else
                        {
                            num = null;
                        }
                    }
                }
                return num;
            }
        }

        // Token: 0x170000B8 RID: 184
        // (get) Token: 0x060001D9 RID: 473 RVA: 0x0000DDF0 File Offset: 0x0000BFF0
        public double? Double
        {
            get
            {
                bool flag = this._paravlue == null;
                double? num;
                if (flag)
                {
                    num = null;
                }
                else
                {
                    try
                    {
                        num = new double?(Convert.ToDouble(this._paravlue));
                    }
                    catch
                    {
                        num = null;
                    }
                }
                return num;
            }
        }

        // Token: 0x170000B9 RID: 185
        // (get) Token: 0x060001DA RID: 474 RVA: 0x0000DE4C File Offset: 0x0000C04C
        public string String
        {
            get
            {
                return (this._paravlue == null) ? "" : this._paravlue.ToString().Trim();
            }
        }

        // Token: 0x170000BA RID: 186
        // (get) Token: 0x060001DB RID: 475 RVA: 0x0000DE80 File Offset: 0x0000C080
        public string Text
        {
            get
            {
                string @string = this.String;
                bool flag = string.IsNullOrWhiteSpace(@string);
                string text;
                if (flag)
                {
                    text = @string;
                }
                else
                {
                    string text2 = Regex.Replace(@string, "<[^>]+>", "");
                    text2 = Regex.Replace(text2, "&[^;]+;", "");
                    text = @string;
                }
                return text;
            }
        }

        // Token: 0x170000BB RID: 187
        // (get) Token: 0x060001DC RID: 476 RVA: 0x0000DECC File Offset: 0x0000C0CC
        public string Value
        {
            get
            {
                string @string = this.String;
                bool flag = string.IsNullOrWhiteSpace(@string);
                string text;
                if (flag)
                {
                    text = null;
                }
                else
                {
                    text = @string;
                }
                return text;
            }
        }

        // Token: 0x170000BC RID: 188
        // (get) Token: 0x060001DD RID: 477 RVA: 0x0000DEF4 File Offset: 0x0000C0F4
        public bool? Boolean
        {
            get
            {
                bool flag = this._paravlue == null;
                bool? flag2;
                if (flag)
                {
                    flag2 = null;
                }
                else
                {
                    try
                    {
                        flag2 = new bool?(Convert.ToBoolean(this._paravlue));
                    }
                    catch
                    {
                        flag2 = null;
                    }
                }
                return flag2;
            }
        }

        // Token: 0x170000BD RID: 189
        // (get) Token: 0x060001DE RID: 478 RVA: 0x0000DF50 File Offset: 0x0000C150
        public DateTime? DateTime
        {
            get
            {
                bool flag = this._paravlue == null;
                DateTime? dateTime;
                if (flag)
                {
                    dateTime = null;
                }
                else
                {
                    try
                    {
                        bool flag2 = this._paravlue is long;
                        if (flag2)
                        {
                            long num = 0L;
                            long.TryParse(this._paravlue.ToString(), out num);
                            DateTime dateTime2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds((double)num);
                            dateTime = new DateTime?(dateTime2);
                        }
                        else
                        {
                            dateTime = new DateTime?(System.DateTime.ParseExact(this._paravlue.ToString(), "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture));
                        }
                    }
                    catch
                    {
                        string text = this._paravlue.ToString();
                        foreach (char c in text)
                        {
                            text += ((c >= '0' && c <= '9') ? c : '-').ToString();
                        }
                        string text3 = text;
                        Regex regex = new Regex("\\-{1,}", RegexOptions.IgnorePatternWhitespace);
                        text3 = regex.Replace(text3, "-");
                        regex = new Regex("^\\-{1,}(\\w)", RegexOptions.IgnorePatternWhitespace);
                        text3 = regex.Replace(text3, "$1");
                        regex = new Regex("(\\w)\\-{1,}$", RegexOptions.IgnorePatternWhitespace);
                        text3 = regex.Replace(text3, "$1");
                        bool flag3 = text3.IndexOf('-') > -1;
                        if (flag3)
                        {
                            string text4 = text3.Substring(0, text3.IndexOf('-'));
                            text4 = ((text4.Length == 1) ? ("0" + text4) : text4);
                            text4 = ((text4.Length == 2) ? ("19" + text4) : text4);
                            text4 = ((text4.Length > 4) ? text4.Substring(0, 4) : text4);
                            text3 = text4 + "-" + text3.Substring(text3.IndexOf('-') + 1);
                        }
                        else
                        {
                            text3 += "-1-1";
                        }
                        try
                        {
                            dateTime = new DateTime?(Convert.ToDateTime(text3));
                        }
                        catch
                        {
                            dateTime = null;
                        }
                    }
                }
                return dateTime;
            }
        }

        // Token: 0x170000BE RID: 190
        // (get) Token: 0x060001DF RID: 479 RVA: 0x0000E1B8 File Offset: 0x0000C3B8
        public string MD5
        {
            get
            {
                bool flag = this._paravlue == null;
                string text;
                if (flag)
                {
                    text = "";
                }
                else
                {
                    bool flag2 = string.IsNullOrWhiteSpace(this._paravlue.ToString());
                    if (flag2)
                    {
                        text = "";
                    }
                    else
                    {
                        MD5 md = System.Security.Cryptography.MD5.Create();
                        byte[] array = md.ComputeHash(Encoding.UTF8.GetBytes(this._paravlue.ToString()));
                        string text2 = string.Empty;
                        for (int i = 0; i < array.Length; i++)
                        {
                            text2 += array[i].ToString("x2");
                        }
                        text = text2;
                    }
                }
                return text;
            }
        }

        //// Token: 0x170000BF RID: 191
        //// (get) Token: 0x060001E0 RID: 480 RVA: 0x0000E25C File Offset: 0x0000C45C
        //public string SHA1
        //{
        //    get
        //    {
        //        bool flag = this._paravlue == null;
        //        string text;
        //        if (flag)
        //        {
        //            text = null;
        //        }
        //        else
        //        {
        //            text = FormsAuthentication.HashPasswordForStoringInConfigFile(this._paravlue.ToString(), "SHA1");
        //        }
        //        return text;
        //    }
        //}

        // Token: 0x170000C0 RID: 192
        // (get) Token: 0x060001E1 RID: 481 RVA: 0x0000E294 File Offset: 0x0000C494
        public string UrlDecode
        {
            get
            {
                bool flag = this._paravlue == null;
                string text;
                if (flag)
                {
                    text = null;
                }
                else
                {
                    text = HttpUtility.UrlDecode(this._paravlue.ToString().Trim());
                }
                return text;
            }
        }

        // Token: 0x170000C1 RID: 193
        // (get) Token: 0x060001E2 RID: 482 RVA: 0x0000E2CC File Offset: 0x0000C4CC
        public string UrlEncode
        {
            get
            {
                bool flag = this._paravlue == null;
                string text;
                if (flag)
                {
                    text = null;
                }
                else
                {
                    text = HttpUtility.UrlEncode(this._paravlue.ToString().Trim());
                }
                return text;
            }
        }

        // Token: 0x170000C2 RID: 194
        // (get) Token: 0x060001E3 RID: 483 RVA: 0x0000E304 File Offset: 0x0000C504
        //public string HtmlDecode
        //{
        //    get
        //    {
        //        bool flag = this._paravlue == null;
        //        string text;
        //        if (flag)
        //        {
        //            text = null;
        //        }
        //        else
        //        {
        //            HttpContext httpContext = HttpContext.Current;
        //            text = httpContext.Server.HtmlDecode(this._paravlue.ToString());
        //        }
        //        return text;
        //    }
        //}

        // Token: 0x170000C3 RID: 195
        // (get) Token: 0x060001E4 RID: 484 RVA: 0x0000E344 File Offset: 0x0000C544
        //public string MapPath
        //{
        //    get
        //    {
        //        return Server.MapPath(this._paravlue.ToString());
        //    }
        //}

        // Token: 0x170000C4 RID: 196
        // (get) Token: 0x060001E5 RID: 485 RVA: 0x0000E368 File Offset: 0x0000C568
        //public string VirtualPath
        //{
        //    get
        //    {
        //        return Server.VirtualPath(this._paravlue.ToString());
        //    }
        //}

        // Token: 0x060001E6 RID: 486 RVA: 0x0000E38C File Offset: 0x0000C58C
        public string[] Split(char split)
        {
            return this._paravlue.ToString().Split(new char[] { split });
        }

        // Token: 0x170000C5 RID: 197
        // (get) Token: 0x060001E7 RID: 487 RVA: 0x0000E3B8 File Offset: 0x0000C5B8
        [Obsolete]
        public string JavascriptTime
        {
            get
            {
                bool flag = this._paravlue == null;
                string text;
                if (flag)
                {
                    text = "";
                }
                else
                {
                    try
                    {
                        DateTime dateTime = this.DateTime ?? TimeZone.CurrentTimeZone.ToLocalTime(System.DateTime.Now);
                        string text2 = "ddd MMM d HH:mm:ss 'UTC'zz'00' yyyy";
                        CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture("en-US");
                        string text3 = dateTime.ToString(text2, cultureInfo);
                        text = text3;
                    }
                    catch
                    {
                        text = "";
                    }
                }
                return text;
            }
        }

        // Token: 0x170000C6 RID: 198
        // (get) Token: 0x060001E8 RID: 488 RVA: 0x0000E448 File Offset: 0x0000C648
        public long TimeStamp
        {
            get
            {
                DateTime dateTime = this.DateTime ?? System.DateTime.Now;
                DateTime dateTime2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
                return (long)(dateTime - dateTime2).TotalMilliseconds;
            }
        }

        // Token: 0x060001E9 RID: 489 RVA: 0x0000E4A8 File Offset: 0x0000C6A8
        public object ChangeType(Type type)
        {
            string fullName = type.FullName;
            string text = fullName;
            object obj;
            if (!(text == "System.DateTime"))
            {
                obj = Convert.ChangeType(this._paravlue, type);
            }
            else
            {
                obj = this.DateTime;
            }
            return obj;
        }

        // Token: 0x060001EA RID: 490 RVA: 0x0000E4F4 File Offset: 0x0000C6F4
        public ConvertToAnyValue Decrypt()
        {
            string text = string.Empty;
            text = DataConvert.DecryptForBase64(this.UrlDecode);
            return new ConvertToAnyValue(text);
        }

        // Token: 0x060001EB RID: 491 RVA: 0x0000E520 File Offset: 0x0000C720
        public static DateTime? ToDateTime(string text)
        {
            bool flag = string.IsNullOrWhiteSpace(text);
            DateTime? dateTime;
            if (flag)
            {
                dateTime = null;
            }
            else
            {
                Regex regex = new Regex("^\\d+$");
                bool flag2 = regex.IsMatch(text.Trim());
                if (flag2)
                {
                    long num = 0L;
                    long.TryParse(text, out num);
                    DateTime dateTime2 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddMilliseconds((double)num);
                    dateTime = new DateTime?(dateTime2);
                }
                else
                {
                    dateTime = new DateTime?(System.DateTime.ParseExact(text, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture));
                }
            }
            return dateTime;
        }

        // Token: 0x04000087 RID: 135
        private object _paravlue;

        // Token: 0x04000088 RID: 136
        private string _parakey = "";

        // Token: 0x04000089 RID: 137
        private string _unit = "";
    }
}
